import _turf from '@/utils/turfUtil'
//图例列表
const list = [
  { lon: '532077.9775', lat: '2500434.72', type: '小型气象站', img: '/poi/小型气象站.png' },
  {
    lon: '532079.03',
    lat: '2500432.96',
    type: '垂直激光测风雷达',
    img: '/poi/垂直激光测风雷达.png'
  },
  { lon: '532080.27', lat: '2500430.88', type: '能见度仪', img: '/poi/能见度仪.png' }
]

//添加起降设施点位地下背景
export async function addQxdev() {
  let markerArr = []
  let customObjectArr = []
  list.forEach((item, index) => {
    let o = {
      id: `qxdev` + index, //maker唯一标识
      coordinate: [Number(item.lon), Number(item.lat)], //坐标位置
      coordinateType: 0, //坐标系类型
      imagePath: `${window.origin}/${item.img}`,
      anchors: [-25, 50],
      imageSize: [50, 50],
      fixedSize: true,
      range: [0, 20000000], //标签的可见范围 [Min,Max]
      autoHidePopupWindow: true,
      groupId: 'qxdev' + item.type,
      displayMode: 2, //显示模式
      autoHeight: true,
      userData: JSON.stringify(item),
      occlusionCull: false
    }
    markerArr.push(o)

    let c = {
      id: 'qxdev-' + index,
      groupId: 'qxdev' + item.type,
      pakFilePath: HostConfig.pakPathLeida, //资源库pak文件路径,推荐使用cloud内置的文件资源管理器加载pak并使用@path方式传入参数
      assetPath: '/JC_CustomAssets/ObjectLibrary/Exhibition/中航/CeFengLeiDa', //资源目录，自定义对象在pak文件资源包里的相对路径
      location: [Number(item.lon), Number(item.lat)], //位置坐标
      coordinateType: 1, // 坐标系类型
      rotation: [0, 0, 0], // 世界坐标系旋转
      localRotation: [0, 90, 0], //模型自身旋转
      scale: [1, 1, 1], //模型缩放
      smoothMotion: 1, //1: 平滑移动，0: 跳跃移动
      autoHeight: true,
      supportAttach: true //不支持贴画贴合
    }
    if (item.type == '大气电场仪') {
      c.assetPath = '/JC_CustomAssets/ObjectLibrary/Exhibition/中航/ChuiZhiCeFengLeiDa'
    }
    customObjectArr.push(c)
  })
  await __g.marker.add(markerArr)
  await __g.customObject.add(customObjectArr)
  __g.camera.set(532165.250674, 2500308.808438, 82.576611, -27.955587, -121.992416, 2)
}

export function clearQx() {
  __g.infoTree.deleteByGroupId('qxdev')
}
